package com.itheima.d01_api_period_duration;

import java.time.LocalDate;
import java.time.Period;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;

/**
 * 目标：了解jdk8提供的时间API，Period 和 Duration
 */
public class Test1 {

    public static void main(String[] args) {
        //需求：统计你未来女朋友和你的出生时间间隔
        LocalDate girlFriend = LocalDate.of(2000, 12, 30);
        LocalDate mine = LocalDate.of(2003, 12, 30);

        //1.创建日期间隔对象
        Period bw = Period.between( girlFriend , mine);
        //2.获取间隔时间
        System.out.println("间隔年："+bw.getYears());
        System.out.println("间隔月："+bw.getMonths());
        System.out.println("间隔天："+bw.getDays());

        //需求：统计你未来女朋友和你间隔的出生天数
        System.out.println("天数："+girlFriend.until(mine, ChronoUnit.DAYS));
    }
}










